package com.sky.loveshop.service.impl;

import com.sky.loveshop.entity.MqttCommand;
import com.sky.loveshop.mapper.MqttCommandMapper;
import com.sky.loveshop.service.MqttCommandService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xcy
 * @version V1.0
 * @description
 * @date 2024/11/17 20:52
 */
@Slf4j
@Service
public class MyMqttCommandServiceImpl implements MqttCommandService {

    @Resource
    private MqttCommandMapper mqttCommandMapper;

    @Override
    public List<MqttCommand> listAll() {
        return mqttCommandMapper.selectAll();
    }

    @Override
    public String getCommandByType(Integer type) {
        Example example = new Example(MqttCommand.class);
        example.createCriteria().andEqualTo("commandType", type);
        MqttCommand mqttCommand = mqttCommandMapper.selectOneByExample(example);
        return mqttCommand.getCommandContent();
    }
}
